package com.lujieni.k8sprovider.controller;


import com.lujieni.k8sprovider.po.StudentPO;
import com.lujieni.k8sprovider.service.IStudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@Slf4j
@RefreshScope //必须加才能监听configMap文件变化
public class HelloController {

    @Autowired
    private IStudentService studentService;

    @Value("${name:local}")
    private String name;



    @GetMapping("/hello")
    public String hello(){
        return "911:"+name;
    }

    @GetMapping("/bye")
    public List<StudentPO> sayBye(HttpServletRequest request) throws InterruptedException {
        log.info("HelloController:sayBye function start");
        return studentService.findAllStudent();
    }


}
